import { request } from '@/utils/request'

export class Resp {
  code: number = 0
  msg: string = ''
  data?: object | null | any
}

export class UploadItem {
  name: string = ''
  url: string = ''
}

export class UploadResponse extends Resp {
  data: UploadItem = new UploadItem()
}

// 文件上传
export async function uploadFile(file: File): Promise<UploadResponse> {
  return request({
    url: '/file/upload',
    method: 'post',
    data: { file },
    headers: {
      'content-type': 'multipart/form-data',
      // 'third-session':
      //   'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0aW1lc3RhbXAiOjE3NDIyNzg2NzQ2MzQsInVpZCI6ImY4MWJjMTY3YjU5MGQ0YWY2YTVkZmQxYWZiZDY2M2Q1In0.OBSkw39z6j2nZvrQhlrKaHnzMnjCF6gpRNVDfJxS8YY',
    },
    // checkToken: true,
  })
}

export interface filePathRequest {
  filePath: string
}

// 通知模型解析文件路径
export async function getFilePath(data: filePathRequest): Promise<Resp> {
  return request({
    url: '/classai/api/file/parseFilePath',
    method: 'post',
    data,
  })
}

export interface practiseRequest {
  groupingId: string
  videoPath: string
  taskId: string
  studentId: string
}

// 小组练习提交
export async function submitPractise(data: practiseRequest): Promise<Resp> {
  return request({
    url: '/classai/api/studentClient/groupPracticeSubmit',
    method: 'post',
    data,
  })
}
export interface homeworkRequest {
  homeworkId: string
  path: string
  analysisId: string
  resourceType?: string
  resourceDescription?: string
}
// 课后作业提交
export async function submitHomeworkRequset(data: homeworkRequest): Promise<Resp> {
  return request({
    url: '/stuclient/api/homework/homeworkSubmit',
    method: 'post',
    data,
  })
}
